<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateKfMybankOrderRecord extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mybank_order_record', function (Blueprint $table) {
            $table->unsignedBigInteger('orderId')->default(0)->comment("订单 Id");
            $table->unsignedBigInteger('shopId')->default(0)->comment("门店 ID");
            $table->string('merchantId', 64)->default('')->comment('商户号');
            $table->string('title', 64)->default('')->comment('订单标题');
            $table->string('remark', 64)->default('')->comment('订单备注');
            $table->integer('brokerage')->default(0)->comment('原账单金额');
            $table->integer('paidBrokerage')->default(0)->comment('已支付的账单金额');
            $table->tinyInteger('type')->default(0)->comment('账单类型 0:默认无意义, 1:佣金账单');
            $table->tinyInteger('payStatus')->default(0)->comment('支付状态 0:未支付 1:支付中 2:已支付 ');
            $table->unsignedInteger('completeAt')->default(0)->comment('完成支付时间');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");

            $table->primary(['orderId'], 'idx_orderId');
            $table->index(['createdAt'], 'idx_createdAt');
            $table->index(['merchantId'], 'idx_merchantId');
            $table->index(['completeAt'], 'idx_completeAt');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '生成的支付订单';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('mybank_order_record');
    }
}
